package logic

import (
	"api/pkg"
	"context"
	"house_srv/house"

	"api/internal/svc"
	"api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type OrderShowLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewOrderShowLogic(ctx context.Context, svcCtx *svc.ServiceContext) *OrderShowLogic {
	return &OrderShowLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *OrderShowLogic) OrderShow(req *types.OrderShowRequest) (resp *types.Response, err error) {
	// todo: add your logic here and delete this line
	show, err := l.svcCtx.HouseSrv.OrderShow(l.ctx, &house.OrderShowRequest{OrderId: req.OrderId})
	if err != nil {
		return &types.Response{
			Code:    500,
			Message: pkg.Tri(err.Error()),
			Data:    nil,
		}, nil
	}
	return &types.Response{
		Code:    200,
		Message: "订单查看成功",
		Data: map[string]interface{}{
			"UserId":      show.UserId,
			"OrderSn":     show.OrderSn,
			"PayType":     show.PayType,
			"PayTime":     show.PayTime,
			"Amount":      show.Amount,
			"OrderStatus": show.OrderStatus,
		},
	}, nil
}
